package leetcodecompetition.D359AC;

/**
 * @Author: Siantar
 * @Date: 2023-08-20-10:40
 * @Description: 1.0
 */
public class T6450 {
    public int minimumSum(int n, int k) {
        int m = (k + 1) / 2;
        if (2 * m - 1 == k) m--;
        if (k == 1) m = 1;
        int cnt = 0, res = 0;
        for (int i = 1; i <= m && cnt < n; i++) {
            res += i;
            cnt++;
        }
        int d = k == 1 ? 2 : k;
        while (cnt < n) {
            res += d;
            d++;
            cnt++;
        }
        return res;
    }
}
